package com.hnkywl.sts.entity.cggl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.organ.Gsjg;
import com.hnkywl.sts.entity.organ.Nbbm;
import com.hnkywl.sts.entity.organ.Nbgs;
import com.hnkywl.sts.entity.organ.Qyjg;
import com.hnkywl.sts.entity.sys.Yg;
import com.hnkywl.sts.entity.xsgl.Xsd;
import com.hnkywl.sts.entity.xsgl.Xsmx;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZHUCHG
 * Date: 13-4-15
 * Time: 下午4:27
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "T_BIZ_JSD")
@Where(clause = "deleted!='1'")
public class Jsd extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqJsd", allocationSize = 1, sequenceName = "SEQ_BIZ_JSD")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqJsd")
    private Long id;
    //  结算单号
    private String jsdh;
    //  申请日期
    private Date sqrq;
    //开票日期
    private Date kprq;
    // 开票人
    @ManyToOne
    @JoinColumn(name = "KPR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg kpr;
    /**
     * 结算类型
     * type=0 采购 ; 1 销售，2物流
     */
    private Integer type;

    // 开票起始开票日（日期）
    private String startDate;

    // 截止开票日（日期）
    private String endDate;

    // 税务月份
    private String swyf;

    // 发票类别代码
    private String fplb;

    //发票号码
    private String hm;

    //发票张数
    private Long fpzs;

    //  关联企业
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GLQY_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg glqy;

    //业务公司
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Gsjg.class)
    @JoinColumn(name = "CGGS_ID")
    private Gsjg cggs;

    //申报公司
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Gsjg.class)
    @JoinColumn(name = "GS_ID")
    private Gsjg gs;

    //申报部门  todo scl6 21 加
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Gsjg.class)
    @JoinColumn(name = "SBBM_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg sbbm;

    // 带总部结算
    private Boolean zbjs;

    //  代垫费用
    private Double ddfy;

    //   净额
    private Double je;

    // 不含税金额（税务系统）
    private Double bhsje;

    // 税额
    private Double se;

    // 税额（税务系统）
    private Double swse;

    // 面额
    private Double me;

    //  税务差额（系统计算结果-税务返回结果）
    private Double ce;

    // 发票总额
    private Double fpze;

    // 发票种类 0、增票 1、普票 2、其他 3、另开票     4、物流发票
    // 1—普通发票，0—专用发票；
    private Long fpzl;

    //    申请人
    @ManyToOne
    @JoinColumn(name = "SQR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg sqr;
    /**
     * 状态类型
     * zt=0 未抛账 ; 1已退回   2已抛账  3 已提交, 4 已导出金税
     */
    private Integer zt;

    private Boolean sftzd = false;

    @ManyToOne
    @JoinColumn(name = "YJSD_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Jsd yjsd;

    /**
     * 发票审核状态类型，财务单据提交
     * zt=0 未审核 ; 1 已审核
     */
    private Integer shzt;

    //    //    关联发票
//    @OneToMany(fetch = FetchType.LAZY, targetEntity = Fp.class, mappedBy = "jsd")
//    @NotFound(action = NotFoundAction.IGNORE)
//    private List<Fp> fpList;
    //   资金补差单
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Zjbcd.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "JSD_ID")
    @Where(clause = "deleted!='1'")
    private List<Zjbcd> zjbcdList;

    // 采购单
    @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, targetEntity = Cgd.class)
    @JoinColumn(name = "CGJS_ID")
    private List<Cgd> cgdList;

    @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, targetEntity = Cgdmx.class)
    @JoinColumn(name = "CGJS_ID")
    private List<Cgdmx> cgdmxList;

    @OneToMany(cascade = CascadeType.MERGE, targetEntity = Xsmx.class)
    @JoinColumn(name = "XSJSD_ID")
    private List<Xsmx> xsdmxList;

    // 销售单
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Xsd.class, mappedBy = "xsjsd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Xsd> xsdList;

    //物流单
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Glfy.class, mappedBy = "wljsd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Glfy> wldList;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Cgjsdmx.class, mappedBy = "jsd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Cgjsdmx> cgjsdmxList;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Xsjsdmx.class, mappedBy = "jsd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Xsjsdmx> xsjsdmxList;

    @OneToMany(fetch = FetchType.LAZY, targetEntity = Wljsdmx.class, mappedBy = "jsd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Wljsdmx> wljsdmxList;

    // 商品明细行数
    @Formula("(select 0 from dual)")
    private Integer num;

    //备注
    private String bz;
    //发票退回原因
    private String fpthyy;

    /**
     * 会计年
     */
    @Column(name = "jiuqi_acctyear")
    private Integer acctyear;
    /**
     * 生成久其凭证时提供的ID
     */
    @Column(name = "jiuqi_uuid")
    private String uuid;
    /**
     * 久其返回的凭证ID
     */
    @Column(name = "jiuqi_voucher_id")
    private String voucherId;
    /**
     * 久其返回的凭证号
     */
    @Column(name = "jiuqi_voucher_num")
    private Integer voucherNum;
    /**
     * “久其插入标示”代码   1=未导入,2=导入开始,3=导入成功
     */
    @Column(name = "jiuqi_insert_flag")
    private Integer insertFlag = 1;
    /**
     * "久其删除标示”代码   1=未删除,2=删除开始,3=删除成功
     */
    @Column(name = "jiuqi_delete_flag")
    private Integer deleteFlag = 1;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "JSDHB_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Jsdhb jsdhb;

    /**
     * 操作状态
     */
    @Transient
    private String czzt;

    //初始化字段  凡是从老系统导入的为初始化字段  置为 1  其他为非初始化
    private String csh;

    /**
     * 导入日期
     */
    private Date drrq;

    public Jsdhb getJsdhb() {
        return jsdhb;
    }

    public void setJsdhb(Jsdhb jsdhb) {
        this.jsdhb = jsdhb;
    }

    public Integer getAcctyear() {
        return acctyear;
    }

    public void setAcctyear(Integer acctyear) {
        this.acctyear = acctyear;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getVoucherId() {
        return voucherId;
    }

    public void setVoucherId(String voucherId) {
        this.voucherId = voucherId;
    }

    public Integer getVoucherNum() {
        return voucherNum;
    }

    public void setVoucherNum(Integer voucherNum) {
        this.voucherNum = voucherNum;
    }

    public Integer getInsertFlag() {
        return insertFlag;
    }

    public void setInsertFlag(Integer insertFlag) {
        this.insertFlag = insertFlag;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getJsdh() {
        return jsdh;
    }

    public void setJsdh(String jsdh) {
        this.jsdh = jsdh;
    }

    public Double getMe() {
        return me;
    }

    public void setMe(Double me) {
        this.me = me;
    }

    public Date getSqrq() {
        return sqrq;
    }

    public void setSqrq(Date sqrq) {
        this.sqrq = sqrq;
    }

    public Integer getShzt() {
        return shzt;
    }

    public void setShzt(Integer shzt) {
        this.shzt = shzt;
    }

    public Gsjg getCggs() {
        return cggs;
    }

    public void setCggs(Gsjg cggs) {
        this.cggs = cggs;
    }

    public void setCggs(Nbgs cggs) {
        this.cggs = cggs;
    }

    public Gsjg getGs() {
        return gs;
    }

    public void setGs(Gsjg gs) {
        this.gs = gs;
    }

    public Boolean getZbjs() {
        return zbjs;
    }

    public void setZbjs(Boolean zbjs) {
        this.zbjs = zbjs;
    }

    public Gsjg getGlqy() {
        return glqy;
    }

    public void setGlqy(Gsjg glqy) {
        this.glqy = glqy;
    }

    public Double getDdfy() {
        return ddfy;
    }

    public void setDdfy(Double ddfy) {
        this.ddfy = ddfy;
    }

    public Double getJe() {
        return je;
    }

    public void setJe(Double je) {
        this.je = je;
    }

    public Double getSe() {
        return se;
    }

    public void setSe(Double se) {
        this.se = se;
    }

    public Yg getSqr() {
        return sqr;
    }

    public void setSqr(Yg sqr) {
        this.sqr = sqr;
    }

    public Integer getZt() {
        return zt;
    }

    public void setZt(Integer zt) {
        this.zt = zt;
    }

//    public List<Fp> getFpList() {
//        return fpList;
//    }
//
//    public void setFpList(List<Fp> fpList) {
//        this.fpList = fpList;
//    }

    public List<Zjbcd> getZjbcdList() {
        return zjbcdList;
    }

    public void setZjbcdList(List<Zjbcd> zjbcdList) {
        this.zjbcdList = zjbcdList;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getHm() {
        return hm;
    }

    public void setHm(String hm) {
        this.hm = hm;
    }

    public Double getFpze() {
        return fpze;
    }

    public void setFpze(Double fpze) {
        this.fpze = fpze;
    }

    public Long getFpzs() {
        return fpzs;
    }

    public void setFpzs(Long fpzs) {
        this.fpzs = fpzs;
    }

    public Long getFpzl() {
        return fpzl;
    }

    public void setFpzl(Long fpzl) {
        this.fpzl = fpzl;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Double getCe() {
        return ce;
    }

    public void setCe(Double ce) {
        this.ce = ce;
    }

    public List<Cgd> getCgdList() {
        return cgdList;
    }

    public void setCgdList(List<Cgd> cgdList) {
        this.cgdList = cgdList;
    }

    public List<Xsd> getXsdList() {
        return xsdList;
    }

    public void setXsdList(List<Xsd> xsdList) {
        this.xsdList = xsdList;
    }

    public List<Glfy> getWldList() {
        return wldList;
    }

    public void setWldList(List<Glfy> wldList) {
        this.wldList = wldList;
    }

    public List<Cgjsdmx> getCgjsdmxList() {
        return cgjsdmxList;
    }

    public void setCgjsdmxList(List<Cgjsdmx> cgjsdmxList) {
        this.cgjsdmxList = cgjsdmxList;
    }

    public List<Xsjsdmx> getXsjsdmxList() {
        return xsjsdmxList;
    }

    public void setXsjsdmxList(List<Xsjsdmx> xsjsdmxList) {
        this.xsjsdmxList = xsjsdmxList;
    }

    public List<Wljsdmx> getWljsdmxList() {
        return wljsdmxList;
    }

    public void setWljsdmxList(List<Wljsdmx> wljsdmxList) {
        this.wljsdmxList = wljsdmxList;
    }

    public Date getKprq() {
        return kprq;
    }

    public void setKprq(Date kprq) {
        this.kprq = kprq;
    }

    public Yg getKpr() {
        return kpr;
    }

    public void setKpr(Yg kpr) {
        this.kpr = kpr;
    }

    public List<Cgdmx> getCgdmxList() {
        return cgdmxList;
    }

    public void setCgdmxList(List<Cgdmx> cgdmxList) {
        this.cgdmxList = cgdmxList;
    }

    public List<Xsmx> getXsdmxList() {
        return xsdmxList;
    }

    public void setXsdmxList(List<Xsmx> xsdmxList) {
        this.xsdmxList = xsdmxList;
    }

    public String getFpthyy() {
        return fpthyy;
    }

    public void setFpthyy(String fpthyy) {
        this.fpthyy = fpthyy;
    }

    public String getCzzt() {
        return czzt;
    }

    public void setCzzt(String czzt) {
        this.czzt = czzt;
    }


    public String getCsh() {
        return csh;
    }

    public Gsjg getSbbm() {
        return sbbm;
    }

    public void setSbbm(Gsjg sbbm) {
        this.sbbm = sbbm;
    }

    public void setCsh(String csh) {
        this.csh = csh;
    }

    public Boolean getSftzd() {
        return sftzd;
    }

    public void setSftzd(Boolean sftzd) {
        this.sftzd = sftzd;
    }

    public Jsd getYjsd() {
        return yjsd;
    }

    public void setYjsd(Jsd yjsd) {
        this.yjsd = yjsd;
    }

    public Date getDrrq() {
        return drrq;
    }

    public void setDrrq(Date drrq) {
        this.drrq = drrq;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getSwyf() {
        return swyf;
    }

    public void setSwyf(String swyf) {
        this.swyf = swyf;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Double getBhsje() {
        return bhsje;
    }

    public void setBhsje(Double bhsje) {
        this.bhsje = bhsje;
    }

    public Double getSwse() {
        return swse;
    }

    public void setSwse(Double swse) {
        this.swse = swse;
    }

    public String getFplb() {
        return fplb;
    }

    public void setFplb(String fplb) {
        this.fplb = fplb;
    }
}
